﻿using GENERIC.Respository.Interfaces;
using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Linq;
using System.Text;

namespace GENERIC.EFRepository
{
    public class EFSet<T> : IGENERICSet<T> where T : class, new()
    {
        #region Constructor

        public EFSet(IObjectSet<T> set)
        {
            Set = set;
        }

        #endregion

        #region Properties

        private IObjectSet<T> Set { get; set; }

        #endregion


        public void Insert(T entity)
        {
            Set.AddObject(entity);
        }

        public void Update(T entity)
        {
            Set.Attach(entity);
        }

        public void Delete(T entity)
        {
            Set.DeleteObject(entity);
        }

        public IQueryable<T> Get()
        {
            return Set.AsQueryable();
        }
    }
}
